package com.prs.crm.dao.crm.impl;


import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Property;

import com.prs.crm.dao.crm.DocumenTaryDao;
import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.domain.crm.Customer;
import com.prs.crm.domain.crm.CustomerAgent;
import com.prs.crm.domain.crm.CustomerProject;
import com.prs.crm.domain.crm.CustomerSupplier;
import com.prs.crm.domain.crm.DocumenTary;
import com.prs.crm.domain.crm.Linkman;

public class DocumenTaryDaoImpl extends BaseDaoImpl<DocumenTary> implements DocumenTaryDao{

	@Override
	public List<DocumenTary> getTaryByid(final Customer customer) {
		Criteria criteria = this.getSession().createCriteria(DocumenTary.class);
		criteria.add(Property.forName("customer").eq(customer));
		return criteria.list();
	}

	@Override
	public List<DocumenTary> getDocumenTaryByCustomerAgent(
			CustomerAgent customerAgent) {
		Criteria criteria = this.getSession().createCriteria(DocumenTary.class);
		criteria.add(Property.forName("customerAgent").eq(customerAgent));
		return criteria.list();
	}

	@Override
	public List<DocumenTary> getDocumenTaryByLinkman(Linkman linkman) {
		Criteria criteria = this.getSession().createCriteria(DocumenTary.class);
		criteria.add(Property.forName("linkman1").eq(linkman));
		return criteria.list();
	}

	@Override
	public List<DocumenTary> getDocumenTaryByCustomerSupplier(
			CustomerSupplier customerSupplier) {
		Criteria criteria = this.getSession().createCriteria(DocumenTary.class);
		criteria.add(Property.forName("customerSupplier").eq(customerSupplier));
		return criteria.list();
	}

	@Override
	public List<DocumenTary> getDocumenTaryByCustomerProject(
			CustomerProject customerProject) {
		Criteria criteria = this.getSession().createCriteria(DocumenTary.class);
		criteria.add(Property.forName("customerProject").eq(customerProject));
		return criteria.list();
	}

}
